home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / gsdbloo.exe / DEMOE002.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-24  |  4KB  |  110 lines

  1. program DemoE002;
  2. {------------------------------------------------------------------------------
  3.                               DBase File Display
  4.                               Expanded Sample 2
  5.                                  Demo Program
  6.  
  7.        Copyright (c)  Richard F. Griffin
  8.  
  9.        10 February 1992
  10.  
  11.        102 Molded Stone Pl
  12.        Warner Robins, GA  31088
  13.  
  14.        -------------------------------------------------------------
  15.        Display and edit all record fields on-screen.  This example also
  16.        allows editing of the memo record.
  17.  
  18.        **********  Not For Use in a TurboVision Environment  **********
  19.  
  20.        If it does not already exist, the DEMOE2.DBF file will be created
  21.        by using the MakeTestData procedure in GS_GENF.PAS.
  22.  
  23.        All fields in the dBase record will be displayed on-screen using
  24.        the FieldDisplay procedure in GS_dBFld_Objt. They can be modified
  25.        and stored back to the dBase file using the FieldAccept procedure.
  26.  
  27. -------------------------------------------------------------------------------}
  28. uses
  29.    CRT,
  30.    DOS,
  31.    GS_KeyI,
  32.    GS_dBFld,
  33.    GS_dBase,
  34.    GS_FileH,
  35.    GS_GenF;
  36. var
  37.    MyFile  : GS_dBFld_Objt;
  38.    CkFile  : file;
  39.    DumyStr : string;
  40.  
  41. procedure DisplayRecord;
  42. begin
  43.   MyFile.FieldDisplay('LASTNAME','Last Name: ',1,1);
  44.    MyFile.FieldDisplay('FIRSTNAME','First Name, Middle Initial: ',1,2);
  45.    MyFile.FieldDisplay('STREET','Street Address: ',1,3);
  46.    MyFile.FieldDisplay('OFFICE','Building, suite, etc: ',1,4);
  47.    MyFile.FieldDisplay('CITY','City: ',1,5);
  48.    MyFile.FieldDisplay('STATE','State: ',1,6);
  49.    MyFile.FieldDisplay('ZIP','Zip Code: ',1,7);
  50.    MyFile.FieldDisplay('TELEPHONE','Telephone Number: ',1,8);
  51.    MyFile.FieldDisplay('BIRTHDATE','Date of Birth: ',1,9);
  52.    MyFile.FieldDisplay('PAYMENT','Payment Amount: ',1,10);
  53.    MyFile.FieldDisplay('PAIDFLAG','Amount Was Paid?: ',1,11);
  54.    MyFile.FieldDisplay('RANDOMNUM','Random Number: ',1,12);
  55.    MyFile.FieldDisplay('COMMENTS','Comments: ',1,13);
  56. end;
  57.  
  58. procedure ModifyRecord;
  59.  
  60.    procedure AcceptRec(FieldName, FieldTitle : string; x, y : integer);
  61.    begin
  62.       DumyStr := MyFile.FieldAccept(FieldName, FieldTitle, x, y);
  63.       if not GS_KeyI_Esc then
  64.          MyFile.FieldPut(FieldName,DumyStr);
  65.    end;
  66.  
  67. begin
  68.    MyFile.RecChanged := false;
  69.   AcceptRec('LASTNAME','Last Name: ',1,1);
  70.    if not GS_KeyI_Esc then AcceptRec('FIRSTNAME',
  71.                                      'First Name, Middle Initial: ',1,2);
  72.    if not GS_KeyI_Esc then AcceptRec('STREET','Street Address: ',1,3);
  73.    if not GS_KeyI_Esc then AcceptRec('OFFICE','Building, suite, etc: ',1,4);
  74.    if not GS_KeyI_Esc then AcceptRec('CITY','City: ',1,5);
  75.    if not GS_KeyI_Esc then AcceptRec('STATE','State: ',1,6);
  76.    if not GS_KeyI_Esc then AcceptRec('ZIP','Zip Code: ',1,7);
  77.    if not GS_KeyI_Esc then AcceptRec('TELEPHONE','Telephone Number: ',1,8);
  78.    if not GS_KeyI_Esc then AcceptRec('BIRTHDATE','Date of Birth: ',1,9);
  79.    if not GS_KeyI_Esc then AcceptRec('PAYMENT','Payment Amount: ',1,10);
  80.    if not GS_KeyI_Esc then AcceptRec('PAIDFLAG','Amount Was Paid?: ',1,11);
  81.    if not GS_KeyI_Esc then AcceptRec('RANDOMNUM','Random Number: ',1,12);
  82.    if not GS_KeyI_Esc then AcceptRec('COMMENTS','Comments: ',1,13);
  83.    if (not GS_KeyI_Esc) and (MyFile.RecChanged) then
  84.       MyFile.PutRec(MyFile.RecNumber);
  85. end;
  86.  
  87.  
  88. begin
  89.    ClrScr;
  90.    if not GS_FileExists(CkFile,'DEMOE2.DBF') then
  91.    begin
  92.       writeln('Creating DemoE2.DBF');
  93.       MakeTestData('DemoE2', 20, true);
  94.       writeln('DemoE2.DBF Created');
  95.       ClrScr;
  96.    end;
  97.    GotoXY(1,15);
  98.    write('Press ESC to stop, any other key to continue');
  99.    MyFile.Init('DemoE2');
  100.    MyFile.Open;
  101.    MyFile.GetRec(Top_Record);
  102.    while (not MyFile.File_EOF) and (not GS_KeyI_Esc) do
  103.    begin
  104.       DisplayRecord;
  105.       ModifyRecord;
  106.       MyFile.GetRec(Next_Record);
  107.    end;
  108.    MyFile.Close;
  109. end.
  110.